<?php
	
	session_start();
	require_once('common/config.php');
	
	if(!isset($_SESSION['logon']))
	{
		header("Location: /wks/login.php?url=menu");
		exit();
	}
	
	$class = $_GET['class'];
	
	if(!defined('BASE_DIR'))
	define('BASE_DIR', $_SERVER['DOCUMENT_ROOT']) ;
	
	
	
	$menu = simplexml_load_file(BASE_DIR."/xml/menu.xml");
	
	if($class == 'makeup')
	{
		$pageCMS = PAGE_CMS_MENU_MAKEUP;
		if(!isset($_POST['submit'])){
			require_once('template/menu/makeup_view.php');
			exit();
		}
		else
		{
			$menu->makeup->makeup1->link = $_POST['makeup_link1']==''? '#':$_POST['makeup_link1'];
			$menu->makeup->makeup1->image = $_POST['makeup_img1'];

			$menu->makeup->makeup2->link = $_POST['makeup_link2']==''? '#':$_POST['makeup_link2'];
			$menu->makeup->makeup2->image = $_POST['makeup_img2'];
			
			$menu->asXML(BASE_DIR."/xml/menu.xml");
			header("Location: /wks/menu.php?class=makeup");
		}
	}
	if($class == 'skincare')
	{
		$pageCMS = PAGE_CMS_MENU_SKINCARE;
		if(!isset($_POST['submit'])){
			require_once('template/menu/skincare_view.php');
			exit();
		}
		else
		{
			$menu->skincare->skincare1->link = $_POST['skincare_link1']==''? '#':$_POST['skincare_link1'];
			$menu->skincare->skincare1->image = $_POST['skincare_img1'];

			$menu->skincare->skincare2->link = $_POST['skincare_link2']==''? '#':$_POST['skincare_link2'];
			$menu->skincare->skincare2->image = $_POST['skincare_img2'];
			
			$menu->asXML(BASE_DIR."/xml/menu.xml");
			header("Location: /wks/menu.php?class=skincare");
		}
	}
	if($class == 'nail')
	{
		$pageCMS = PAGE_CMS_MENU_NAIL;
		if(!isset($_POST['submit'])){
			require_once('template/menu/nail_view.php');
			exit();
		}
		else
		{
			$menu->nail->nail1->link = $_POST['nail_link1']==''? '#':$_POST['nail_link1'];
			$menu->nail->nail1->image = $_POST['nail_img1'];

			$menu->nail->nail2->link = $_POST['nail_link2']==''? '#':$_POST['nail_link2'];
			$menu->nail->nail2->image = $_POST['nail_img2'];
			
			$menu->asXML(BASE_DIR."/xml/menu.xml");
			header("Location: /wks/menu.php?class=nail");
		}
	}
	if($class == 'hair')
	{
		$pageCMS = PAGE_CMS_MENU_HAIR;
		if(!isset($_POST['submit'])){
			require_once('template/menu/hair_view.php');
			exit();
		}
		else
		{
			$menu->hair->hair1->link = $_POST['hair_link1']==''? '#':$_POST['hair_link1'];
			$menu->hair->hair1->image = $_POST['hair_img1'];

			$menu->hair->hair2->link = $_POST['hair_link2']==''? '#':$_POST['hair_link2'];
			$menu->hair->hair2->image = $_POST['hair_img2'];
			
			$menu->asXML(BASE_DIR."/xml/menu.xml");
			header("Location: /wks/menu.php?class=hair");
		}
	}
	if($class == 'men')
	{
		$pageCMS = PAGE_CMS_MENU_MEN;
		if(!isset($_POST['submit'])){
			require_once('template/menu/men_view.php');
			exit();
		}
		else
		{
			$menu->men->men1->link = $_POST['men_link1']==''? '#':$_POST['men_link1'];
			$menu->men->men1->image = $_POST['men_img1'];

			$menu->asXML(BASE_DIR."/xml/menu.xml");
			header("Location: /wks/menu.php?class=men");
		}
	}
?>


